import request from '../../utils/request.js'

// 获取题目列表
export function listPractice(data, url) {
  // console.log('/practice'+url)
  return request({
    url: '/practice'+url,
    method: 'get',
    params: data
  })
}
// 删除题目
export function deletePractice(id){
  return request({
    url: '/practice/delete/'+id,
    method: 'delete',
  })
}

//获取单个题目信息
export function getPractice(id) {
  return request({
    url: '/practice/'+id,
    method: 'get',
  })
}

// 新增题目
export function insertPractice(data) {
  return request({
    url: '/practice/insert',
    method: 'post',
    data: data
  })
}

//修改题目
export function updatePractice(data) {
  return request({
    url: '/practice/update',
    method: 'put',
    data: data
  })
}

//收藏题目
export function collectPractice(id) {
  return request({
    url: '/practice/collect/'+id,
    method: 'post',
  })
}


// 添加题目选项
export function insertOptions(type,data) {
  return request({
    url: '/practice/insert/choiceoptions/'+type,
    method: 'post',
    data: data
  })
}
//修改题目选项
export function updateOptions(type,data) {
  return request({
    url: '/practice/update/choiceoptions/'+type,
    method: 'put',
    data: data
  })
}

// 删除题目选项
export function deleteOptions(id) {
  return request({
    url: '/practice/delete/choiceoptions/'+id,
    method: 'delete',
  })
}

//查看题目选项
export function getOptions(id) {
  return request({
    url: '/practice/choiceoptions/'+id,
    method: 'get',
  })
}

// 查看题目历史记录
export function listPracticeHistory(data) {
  return request({
    url: '/practice/list/history',
    method: 'get',
    params: data
  })
}

// 提交题目答案
export function submitPracticeAnswer(id,answer) {
  return request({
    url: '/aiChat/submitPracticeAnswer?id=' + id + "&answer=" + answer,
    method: 'post'
  })
}

// 获取ai提示
export function getAiTips(id) {
  return request({
    url: '/aiChat/getAiTip?id=' + id,
    method: 'get'
  })
}

//获取专业数组
export function listSubject() {
   return request({
    url: '/practice/list/subject',
    method: 'get',
  })
}